AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()
	self.Entity:SetModel("models/hunter/blocks/cube1x1x025.mdl")
	self.Entity:SetSkin(0)
	self.Entity:SetSolid(SOLID_VPHYSICS)
	local phys = self.Entity:GetPhysicsObject()
	if phys and phys:IsValid() then phys:Wake() end

end

function ENT:SpawnFunction( ply, tr ) 
   
 	if ( !tr.Hit ) then return end 
 	 
 	local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 	 
 	local ent = ents.Create( self.Classname ) 
 		ent:SetPos( SpawnPos ) 
 	ent:Spawn() 
 	ent:Activate() 
 	 
 	return ent 
 	 
 end 
 
 
local isTouching = false

local XZ = { 

	"X = math.Rand( 256, 512 )",
	"Z = math.Rand( 256, 512 )"

}
local Y = math.Rand ( 128, 256 )
local xztable = table.Random(XZ)

local slapSounds = {
	"physics/body/body_medium_impact_hard1.wav",
	"physics/body/body_medium_impact_hard2.wav",
	"physics/body/body_medium_impact_hard3.wav",
	"physics/body/body_medium_impact_hard5.wav",
	"physics/body/body_medium_impact_hard6.wav",
	"physics/body/body_medium_impact_soft5.wav",
	"physics/body/body_medium_impact_soft6.wav",
	"physics/body/body_medium_impact_soft7.wav",
}

 
function ENT:StartTouch( ent )
      if ( IsValid(ent) and ent:IsPlayer() ) then
		
            isTouching = true
        end
end

function ENT:Touch( ent )
    if ( isTouching ) then
						ent:EmitSound( slapSounds[math.random(#slapSounds)], 100, 100 )
						ent:SetVelocity( Vector(0,512,0), Vector (512,0,0) )
						ent:ViewPunch( Angle( math.random( -70, 70 ), math.random( -70, 70 ), 0 ) )
        end
    end

function ENT:EndTouch( ent )
       if ( IsValid(ent) and ent:IsPlayer() ) then
            isTouching = false
        end
end

function ENT:Think() 
end

